<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 整数拆分 -->
    <script>
      var integerBreak = function (n) {
        if (n <= 3) return n - 1
        let a = ~~(n / 3),
          b = n % 3
        if (!b) return 3 ** a
        if (b === 1) return 3 ** (a - 1) * 4
        return 3 ** a * 2
      }
      console.log(integerBreak(2))
    </script>
  </body>
</html>
